<%@ page language="java" import="java.util.*,com.inspur.bean.User" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'EL02.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
		<%
			//数组
			String[] names={"张三","王五","李四"};
			request.setAttribute("names", names);
		
			//list集合
			List<String> list=new ArrayList<String>();
			list.add("Java语言");
		    list.add("JSP程序设计");
			list.add("Web");
			request.setAttribute("list", list);
			
			
			//迭代复杂类型的List集合
			List<User> list1=new ArrayList<User>();
			User user1=new User(12,"张三",26);
			User user2=new User(13,"李四",29);
			User user3=new User(14,"王五",30);
			list1.add(user1);
			list1.add(user2);
			list1.add(user3);
			request.setAttribute("list1", list1);
			
			
			//map集合
			Map<String,Double> map=new HashMap<String,Double>();
			map.put("张三",8000.00);
			map.put("李四",9000.00);
			map.put("王五",10000.00);
			request.setAttribute("map",map);
		 %>
		 
		 <!-- 如果想要使用JSTL中的forEach标签。必须通过taglib指令引入核心标签库 -->
		姓名值： 
		<c:forEach items="${names}" var="name">
			${name }
		</c:forEach>
		 <br/>
		 迭代list集合：
		 <c:forEach items="${list}" var="list1">
		 	${list1 }
		 </c:forEach>
		 <br/>
		 迭代复杂类型的List集合:
		 
		 <table>
		 	<tr>
		 		<td>编号：</td>
		 		<td>姓名：</td>
		 		<td>年龄：</td>
		 	</tr>
		 	 <c:forEach items="${list1 }" var="list2">
			 	<tr>
			 		<td>${list2.userId }</td>
			 		<td>${list2.userName }</td>
			 		<td>${list2.userAge }</td>
			 	</tr>
		 	 </c:forEach>
		 
		 
		 </table>
		 <br/>
		 
		 迭代map集合：
		 <c:forEach items="${map}" var="maps">
		 	${maps.key }||${maps.value }
		 </c:forEach>
		 
		
		 	
		 
		 

  </body>
</html>
